﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FreedomX2.Core.Transport.SocketProvider
{
    public enum PType
    {
        Message = 0,
        FileBlocks = 1,
        Resource = 2,
        Closed = 3
    }
    public class ProtocolVar
    {
        public static string APPCONFIGIPNAME = "localip";
        public static string DefaultIP = "127.0.0.1";
        public static int DefaultPort = 61011;
        private static string localIP = "";
        public static string LocationIP
        {
            get
            {
                if (localIP == "")
                {
                    while (true)
                    {
                        try { localIP = IO.ConfigDynamic.Pub.GetAppValue(APPCONFIGIPNAME).ToString(); }
                        catch { }

                        if (localIP != "") break;
                        FrmSocketChoose fsc = new FrmSocketChoose();
                        var v = fsc.ShowDialog();
                        if (v == System.Windows.Forms.DialogResult.OK)
                            localIP = fsc.Result;

                        if (localIP != "") break;
                    }
                }


                return localIP;


            }
        }
        public static int DefaultPackageSize
        {
            get { return SocketBlocks.PackageSize; }
            set { SocketBlocks.PackageSize = value; }
        }
        public static int DefaultPackageContentSize
        {
            get { return DefaultPackageSize - SocketBlocks.HeadIDLength - SocketBlocks.HeadLogoLength - SocketBlocks.FootSizeLength - SocketBlocks.FootCustomLength; }
        }

    }
}
